package com.zr.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.dao.impl.ZLCSuserdaoimpl;
import com.zr.service.mainserver;
import com.zr.service.impl.mainserverimpl;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class Getalluser extends HttpServlet{
	/*
	 * zl
	 * 获得用户数据列表
	 * 
	 * */
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		resp.setCharacterEncoding("utf8");
		String page = req.getParameter("page");
		String row = req.getParameter("rows");
		int state = (Integer.parseInt(page)-1)*Integer.parseInt(row);
		int rows = Integer.parseInt(row);
		//ZLCSuserdaoimpl user =new ZLCSuserdaoimpl();
		mainserver ms =new mainserverimpl();
		JSONObject jsons =new JSONObject();
		//获得datagrid 返回对象rows，totals
		jsons.put("rows", ms.alluser(state,rows));
		jsons.put("total",ms.count());
		
		PrintWriter pw = resp.getWriter();
		pw.write(jsons.toString());
		
		
		
	}

}
